// -ml:std = c++03
#include "debug.hh"
#include "geometry.hh"
#include <iostream>
#include <iterator>
#include <vector>
#include <set>

int main()
{
    typedef std::vector<tue::geometry>  geom_list;
    typedef std::set   <tue::vec2, tue::tolerant_less> point_list;
    typedef  geom_list::iterator  geom_iter;
//  typedef point_list::iterator point_iter;

    // parse input
    int nseg, nray, nline, ncircle;
    std::cin >> nseg >> nray >> nline >> ncircle;

    geom_list geoms;
    geoms.reserve(nseg + nray + nline + ncircle);

    while (nseg--) geoms.push_back(tue::geometry(std::cin, false, false));
    while (nray--) geoms.push_back(tue::geometry(std::cin, false, true));
    while (nline--) geoms.push_back(tue::geometry(std::cin, true, true));
    while (ncircle--) geoms.push_back(tue::geometry(std::cin));

    // find intersections
    point_list points;
    for (geom_iter last=geoms.end(),it=geoms.begin(); it != last; ++it)
        for (geom_iter with=it+1; with != last; ++with)
            intersect(std::inserter(points, points.end()), *it, *with);

    // output
    DEBUG(
        for (auto & p: points)
            std::cerr << p << "\n";
    );
    std::cout << points.size() << "\n";
}

// ml:run = sed '0,/^=input/d; /^=end/,$d' $src | $bin
/*
=input
3 3 3 3
6 18 49 39
80 29 67 34
90 76 10 4
91 39 69 -1
53 57 8 -36
37 19 85 -67
56 30 106 25
24 23 65 -33
40 9 66 55
22 58 12
13 11 7
1 23 1
=end
*/

